import 'package:dio/dio.dart';
// import 'package:myapp/components/Logger/loggers.dart';

class LogInterceptor extends Interceptor {
  @override
  void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
    // 获取并设置Token
    const token = 'YOUR_TOKEN_HERE'; // 实际应用中，Token通常是动态获取的
    options.headers['Authorization'] = 'Bearer $token';
    // logger.t("Request: ${options.method} ${options.path}");
    super.onRequest(options, handler);
  }

  @override
  void onResponse(Response response, ResponseInterceptorHandler handler) {
    // logger.t("Response: ${response.statusCode} ${response.data}");
    super.onResponse(response, handler);
  }

  @override
  void onError(DioException err, ErrorInterceptorHandler handler) {
    // logger.e("Error: ${err.type} ${err.message}");
    super.onError(err, handler);
  }
}
